mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 795053 - Add ability to unlock a profile from Java. r=blassey
This commit is contained in:
parent
3e8fb83225
commit
f84327cacf
@ -2261,4 +2261,18 @@ public class GeckoAppShell
|
|||||||
if (GeckoApp.mAppContext != null)
|
if (GeckoApp.mAppContext != null)
|
||||||
GeckoApp.mAppContext.notifyCheckUpdateResult(result);
|
GeckoApp.mAppContext.notifyCheckUpdateResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean unlockProfile() {
|
||||||
|
// Try to kill any zombie Fennec's that might be running
|
||||||
|
GeckoAppShell.killAnyZombies();
|
||||||
|
|
||||||
|
// Then force unlock this profile
|
||||||
|
GeckoProfile profile = GeckoApp.mAppContext.getProfile();
|
||||||
|
File lock = profile.getFile(".parentlock");
|
||||||
|
if (lock.exists()) {
|
||||||
|
lock.delete();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1746,10 +1746,15 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
|
|||||||
// The actual value is irrelevant but we shouldn't be handing out
|
// The actual value is irrelevant but we shouldn't be handing out
|
||||||
// malformed JSBools to XPConnect.
|
// malformed JSBools to XPConnect.
|
||||||
bool checkState = false;
|
bool checkState = false;
|
||||||
|
#ifdef ANDROID
|
||||||
|
mozilla::AndroidBridge::Bridge()->KillAnyZombies();
|
||||||
|
button = 1;
|
||||||
|
#else
|
||||||
rv = ps->ConfirmEx(nullptr, killTitle, killMessage, flags,
|
rv = ps->ConfirmEx(nullptr, killTitle, killMessage, flags,
|
||||||
killTitle, nullptr, nullptr, nullptr,
|
killTitle, nullptr, nullptr, nullptr,
|
||||||
&checkState, &button);
|
&checkState, &button);
|
||||||
NS_ENSURE_SUCCESS_LOG(rv, rv);
|
NS_ENSURE_SUCCESS_LOG(rv, rv);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (button == 1) {
|
if (button == 1) {
|
||||||
rv = aUnlocker->Unlock(nsIProfileUnlocker::FORCE_QUIT);
|
rv = aUnlocker->Unlock(nsIProfileUnlocker::FORCE_QUIT);
|
||||||
@ -1760,8 +1765,13 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
|
|||||||
nullptr, aResult);
|
nullptr, aResult);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef ANDROID
|
||||||
|
if (mozilla::AndroidBridge::Bridge()->UnlockProfile())
|
||||||
|
return NS_OK;
|
||||||
|
#else
|
||||||
rv = ps->Alert(nullptr, killTitle, killMessage);
|
rv = ps->Alert(nullptr, killTitle, killMessage);
|
||||||
NS_ENSURE_SUCCESS_LOG(rv, rv);
|
NS_ENSURE_SUCCESS_LOG(rv, rv);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_ERROR_ABORT;
|
return NS_ERROR_ABORT;
|
||||||
|
@ -122,6 +122,8 @@ AndroidBridge::Init(JNIEnv *jEnv,
|
|||||||
jShowFilePickerForExtensions = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showFilePickerForExtensions", "(Ljava/lang/String;)Ljava/lang/String;");
|
jShowFilePickerForExtensions = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showFilePickerForExtensions", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||||
jShowFilePickerForMimeType = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showFilePickerForMimeType", "(Ljava/lang/String;)Ljava/lang/String;");
|
jShowFilePickerForMimeType = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showFilePickerForMimeType", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||||
jShowFilePickerAsync = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showFilePickerAsync", "(Ljava/lang/String;J)V");
|
jShowFilePickerAsync = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showFilePickerAsync", "(Ljava/lang/String;J)V");
|
||||||
|
jUnlockProfile = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "unlockProfile", "()Z");
|
||||||
|
jKillAnyZombies = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "killAnyZombies", "()V");
|
||||||
jAlertsProgressListener_OnProgress = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "alertsProgressListener_OnProgress", "(Ljava/lang/String;JJLjava/lang/String;)V");
|
jAlertsProgressListener_OnProgress = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "alertsProgressListener_OnProgress", "(Ljava/lang/String;JJLjava/lang/String;)V");
|
||||||
jAlertsProgressListener_OnCancel = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "alertsProgressListener_OnCancel", "(Ljava/lang/String;)V");
|
jAlertsProgressListener_OnCancel = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "alertsProgressListener_OnCancel", "(Ljava/lang/String;)V");
|
||||||
jGetDpi = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getDpi", "()I");
|
jGetDpi = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getDpi", "()I");
|
||||||
@ -2539,6 +2541,30 @@ AndroidBridge::NotifyPaintedRect(float top, float left, float bottom, float righ
|
|||||||
top, left, bottom, right);
|
top, left, bottom, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AndroidBridge::KillAnyZombies()
|
||||||
|
{
|
||||||
|
JNIEnv* env = GetJNIEnv();
|
||||||
|
if (!env)
|
||||||
|
return;
|
||||||
|
env->CallStaticVoidMethod(mGeckoAppShellClass, AndroidBridge::Bridge()->jKillAnyZombies);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
AndroidBridge::UnlockProfile()
|
||||||
|
{
|
||||||
|
JNIEnv* env = GetJNIEnv();
|
||||||
|
if (!env)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AutoLocalJNIFrame jniFrame(env, 0);
|
||||||
|
bool ret = env->CallStaticBooleanMethod(mGeckoAppShellClass, jUnlockProfile);
|
||||||
|
if (jniFrame.CheckForException())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
__attribute__ ((visibility("default")))
|
__attribute__ ((visibility("default")))
|
||||||
jclass
|
jclass
|
||||||
|
@ -279,6 +279,10 @@ public:
|
|||||||
|
|
||||||
void UnlockBitmap(jobject bitmap);
|
void UnlockBitmap(jobject bitmap);
|
||||||
|
|
||||||
|
bool UnlockProfile();
|
||||||
|
|
||||||
|
void KillAnyZombies();
|
||||||
|
|
||||||
/* Copied from Android's native_window.h in newer (platform 9) NDK */
|
/* Copied from Android's native_window.h in newer (platform 9) NDK */
|
||||||
enum {
|
enum {
|
||||||
WINDOW_FORMAT_RGBA_8888 = 1,
|
WINDOW_FORMAT_RGBA_8888 = 1,
|
||||||
@ -417,6 +421,8 @@ protected:
|
|||||||
jmethodID jShowFilePickerForExtensions;
|
jmethodID jShowFilePickerForExtensions;
|
||||||
jmethodID jShowFilePickerForMimeType;
|
jmethodID jShowFilePickerForMimeType;
|
||||||
jmethodID jShowFilePickerAsync;
|
jmethodID jShowFilePickerAsync;
|
||||||
|
jmethodID jUnlockProfile;
|
||||||
|
jmethodID jKillAnyZombies;
|
||||||
jmethodID jAlertsProgressListener_OnProgress;
|
jmethodID jAlertsProgressListener_OnProgress;
|
||||||
jmethodID jAlertsProgressListener_OnCancel;
|
jmethodID jAlertsProgressListener_OnCancel;
|
||||||
jmethodID jGetDpi;
|
jmethodID jGetDpi;
|
||||||
|
Loading…
Reference in New Issue
Block a user