Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server; |
| 18 | |
| 19 | import android.content.Context; |
Jeff Sharkey | 847bd85 | 2016-08-03 17:20:03 -0600 | [diff] [blame] | 20 | import android.content.Intent; |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 21 | import android.content.pm.ActivityInfo; |
| 22 | import android.content.pm.ApplicationInfo; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 23 | import android.content.pm.PackageManager; |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 24 | import android.content.pm.ResolveInfo; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 25 | import android.os.Binder; |
| 26 | import android.os.Build; |
Philip Cuadra | a95cea0 | 2016-07-06 16:00:32 -0700 | [diff] [blame] | 27 | import android.os.Handler; |
| 28 | import android.os.Looper; |
| 29 | import android.os.Message; |
Jeff Sharkey | 847bd85 | 2016-08-03 17:20:03 -0600 | [diff] [blame] | 30 | import android.os.UserHandle; |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 31 | import android.provider.MediaStore; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 32 | import android.system.ErrnoException; |
| 33 | import android.system.Os; |
| 34 | import android.system.OsConstants; |
| 35 | import android.system.StructStat; |
Jeff Sharkey | 847bd85 | 2016-08-03 17:20:03 -0600 | [diff] [blame] | 36 | import android.util.Slog; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 37 | |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 38 | import com.android.internal.app.ResolverActivity; |
Philip Cuadra | a95cea0 | 2016-07-06 16:00:32 -0700 | [diff] [blame] | 39 | import com.android.internal.os.BackgroundThread; |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 40 | |
Philip Cuadra | d9bd884 | 2016-07-12 17:29:38 -0700 | [diff] [blame] | 41 | import dalvik.system.DexFile; |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 42 | import dalvik.system.VMRuntime; |
| 43 | |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 44 | import java.io.FileDescriptor; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 45 | import java.io.IOException; |
| 46 | import java.io.PrintWriter; |
Jeff Sharkey | 847bd85 | 2016-08-03 17:20:03 -0600 | [diff] [blame] | 47 | import java.util.ArrayList; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * <p>PinnerService pins important files for key processes in memory.</p> |
| 51 | * <p>Files to pin are specified in the config_defaultPinnerServiceFiles |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 52 | * overlay.</p> |
| 53 | * <p>Pin the default camera application if specified in config_pinnerCameraApp.</p> |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 54 | */ |
| 55 | public final class PinnerService extends SystemService { |
| 56 | private static final boolean DEBUG = false; |
| 57 | private static final String TAG = "PinnerService"; |
| 58 | |
| 59 | private final Context mContext; |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 60 | private final ArrayList<PinnedFile> mPinnedFiles = new ArrayList<PinnedFile>(); |
| 61 | private final ArrayList<PinnedFile> mPinnedCameraFiles = new ArrayList<PinnedFile>(); |
| 62 | private final boolean mShouldPinCamera; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 63 | |
| 64 | private BinderService mBinderService; |
| 65 | |
Philip Cuadra | ac39b96 | 2016-11-02 11:59:22 -0700 | [diff] [blame] | 66 | private final long MAX_CAMERA_PIN_SIZE = 80 * (1 << 20); //80MB max |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 67 | |
Philip Cuadra | a95cea0 | 2016-07-06 16:00:32 -0700 | [diff] [blame] | 68 | private PinnerHandler mPinnerHandler = null; |
| 69 | |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 70 | |
| 71 | public PinnerService(Context context) { |
| 72 | super(context); |
| 73 | |
| 74 | mContext = context; |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 75 | mShouldPinCamera = context.getResources().getBoolean( |
| 76 | com.android.internal.R.bool.config_pinnerCameraApp); |
Philip Cuadra | a95cea0 | 2016-07-06 16:00:32 -0700 | [diff] [blame] | 77 | mPinnerHandler = new PinnerHandler(BackgroundThread.get().getLooper()); |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public void onStart() { |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 82 | if (DEBUG) { |
| 83 | Slog.i(TAG, "Starting PinnerService"); |
| 84 | } |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 85 | mBinderService = new BinderService(); |
| 86 | publishBinderService("pinner", mBinderService); |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 87 | |
Jeff Sharkey | 847bd85 | 2016-08-03 17:20:03 -0600 | [diff] [blame] | 88 | mPinnerHandler.obtainMessage(PinnerHandler.PIN_ONSTART_MSG).sendToTarget(); |
| 89 | mPinnerHandler.obtainMessage(PinnerHandler.PIN_CAMERA_MSG, UserHandle.USER_SYSTEM, 0) |
| 90 | .sendToTarget(); |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | /** |
Philip Cuadra | a95cea0 | 2016-07-06 16:00:32 -0700 | [diff] [blame] | 94 | * Pin camera on user switch. |
| 95 | * If more than one user is using the device |
| 96 | * each user may set a different preference for the camera app. |
| 97 | * Make sure that user's preference is pinned into memory. |
| 98 | */ |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 99 | @Override |
| 100 | public void onSwitchUser(int userHandle) { |
Jeff Sharkey | 847bd85 | 2016-08-03 17:20:03 -0600 | [diff] [blame] | 101 | mPinnerHandler.obtainMessage(PinnerHandler.PIN_CAMERA_MSG, userHandle, 0).sendToTarget(); |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Philip Cuadra | a95cea0 | 2016-07-06 16:00:32 -0700 | [diff] [blame] | 104 | /** |
| 105 | * Handler for on start pinning message |
| 106 | */ |
| 107 | private void handlePinOnStart() { |
| 108 | // Files to pin come from the overlay and can be specified per-device config |
| 109 | String[] filesToPin = mContext.getResources().getStringArray( |
| 110 | com.android.internal.R.array.config_defaultPinnerServiceFiles); |
| 111 | synchronized(this) { |
| 112 | // Continue trying to pin remaining files even if there is a failure |
| 113 | for (int i = 0; i < filesToPin.length; i++){ |
| 114 | PinnedFile pf = pinFile(filesToPin[i], 0, 0, 0); |
| 115 | if (pf != null) { |
| 116 | mPinnedFiles.add(pf); |
| 117 | if (DEBUG) { |
| 118 | Slog.i(TAG, "Pinned file = " + pf.mFilename); |
| 119 | } |
| 120 | } else { |
| 121 | Slog.e(TAG, "Failed to pin file = " + filesToPin[i]); |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Handler for camera pinning message |
| 129 | */ |
| 130 | private void handlePinCamera(int userHandle) { |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 131 | if (mShouldPinCamera) { |
Philip Cuadra | a95cea0 | 2016-07-06 16:00:32 -0700 | [diff] [blame] | 132 | synchronized(this) { |
| 133 | boolean success = pinCamera(userHandle); |
| 134 | if (!success) { |
| 135 | //this is not necessarily an error |
| 136 | if (DEBUG) { |
| 137 | Slog.v(TAG, "Failed to pin camera."); |
| 138 | } |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 139 | } |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * determine if the camera app is already pinned by comparing the |
| 146 | * intent resolution to the pinned files list |
| 147 | */ |
| 148 | private boolean alreadyPinned(int userHandle) { |
| 149 | ApplicationInfo cameraInfo = getCameraInfo(userHandle); |
| 150 | if (cameraInfo == null ) { |
| 151 | return false; |
| 152 | } |
| 153 | for (int i = 0; i < mPinnedCameraFiles.size(); i++) { |
| 154 | if (mPinnedCameraFiles.get(i).mFilename.equals(cameraInfo.sourceDir)) { |
| 155 | if (DEBUG) { |
| 156 | Slog.v(TAG, "Camera is already pinned"); |
| 157 | } |
| 158 | return true; |
| 159 | } |
| 160 | } |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | private void unpinCameraApp() { |
| 165 | for (int i = 0; i < mPinnedCameraFiles.size(); i++) { |
| 166 | unpinFile(mPinnedCameraFiles.get(i)); |
| 167 | } |
| 168 | mPinnedCameraFiles.clear(); |
| 169 | } |
| 170 | |
| 171 | private boolean isResolverActivity(ActivityInfo info) { |
| 172 | return ResolverActivity.class.getName().equals(info.name); |
| 173 | } |
| 174 | |
| 175 | private ApplicationInfo getCameraInfo(int userHandle) { |
| 176 | // find the camera via an intent |
| 177 | // use INTENT_ACTION_STILL_IMAGE_CAMERA instead of _SECURE. On a |
| 178 | // device without a fbe enabled, the _SECURE intent will never get set. |
| 179 | Intent cameraIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); |
| 180 | PackageManager pm = mContext.getPackageManager(); |
Jeff Sharkey | 847bd85 | 2016-08-03 17:20:03 -0600 | [diff] [blame] | 181 | ResolveInfo cameraResolveInfo = pm.resolveActivityAsUser(cameraIntent, |
| 182 | PackageManager.MATCH_DEFAULT_ONLY | PackageManager.MATCH_DIRECT_BOOT_AWARE |
| 183 | | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, |
| 184 | userHandle); |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 185 | if (cameraResolveInfo == null ) { |
| 186 | //this is not necessarily an error |
| 187 | if (DEBUG) { |
| 188 | Slog.v(TAG, "Unable to resolve camera intent"); |
| 189 | } |
| 190 | return null; |
| 191 | } |
| 192 | |
| 193 | if (isResolverActivity(cameraResolveInfo.activityInfo)) |
| 194 | { |
Philip Cuadra | ac39b96 | 2016-11-02 11:59:22 -0700 | [diff] [blame] | 195 | if (DEBUG) { |
| 196 | Slog.v(TAG, "cameraIntent returned resolverActivity"); |
| 197 | } |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 198 | return null; |
| 199 | } |
| 200 | |
| 201 | return cameraResolveInfo.activityInfo.applicationInfo; |
| 202 | } |
| 203 | |
| 204 | private boolean pinCamera(int userHandle){ |
| 205 | //we may have already pinned a camera app. If we've pinned this |
| 206 | //camera app, we're done. otherwise, unpin and pin the new app |
| 207 | if (alreadyPinned(userHandle)){ |
| 208 | return true; |
| 209 | } |
| 210 | |
| 211 | ApplicationInfo cameraInfo = getCameraInfo(userHandle); |
| 212 | if (cameraInfo == null) { |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | //unpin after checking that the camera intent has resolved |
| 217 | //this prevents us from thrashing when switching users with |
| 218 | //FBE enabled, because the intent won't resolve until the unlock |
| 219 | unpinCameraApp(); |
| 220 | |
| 221 | //pin APK |
| 222 | String camAPK = cameraInfo.sourceDir; |
| 223 | PinnedFile pf = pinFile(camAPK, 0, 0, MAX_CAMERA_PIN_SIZE); |
| 224 | if (pf == null) { |
| 225 | Slog.e(TAG, "Failed to pin " + camAPK); |
| 226 | return false; |
| 227 | } |
| 228 | if (DEBUG) { |
| 229 | Slog.i(TAG, "Pinned " + pf.mFilename); |
| 230 | } |
| 231 | mPinnedCameraFiles.add(pf); |
| 232 | |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 233 | // determine the ABI from either ApplicationInfo or Build |
| 234 | String arch = "arm"; |
| 235 | if (cameraInfo.primaryCpuAbi != null |
| 236 | && VMRuntime.is64BitAbi(cameraInfo.primaryCpuAbi)) { |
| 237 | arch = arch + "64"; |
| 238 | } else { |
| 239 | if (VMRuntime.is64BitAbi(Build.SUPPORTED_ABIS[0])) { |
| 240 | arch = arch + "64"; |
| 241 | } |
| 242 | } |
Philip Cuadra | d9bd884 | 2016-07-12 17:29:38 -0700 | [diff] [blame] | 243 | |
| 244 | // get the path to the odex or oat file |
| 245 | String baseCodePath = cameraInfo.getBaseCodePath(); |
Calin Juravle | 8e0f959 | 2017-05-15 20:20:50 -0700 | [diff] [blame] | 246 | String[] files = null; |
Philip Cuadra | d9bd884 | 2016-07-12 17:29:38 -0700 | [diff] [blame] | 247 | try { |
Calin Juravle | 8e0f959 | 2017-05-15 20:20:50 -0700 | [diff] [blame] | 248 | files = DexFile.getDexFileOutputPaths(baseCodePath, arch); |
Philip Cuadra | d9bd884 | 2016-07-12 17:29:38 -0700 | [diff] [blame] | 249 | } catch (IOException ioe) {} |
Calin Juravle | 8e0f959 | 2017-05-15 20:20:50 -0700 | [diff] [blame] | 250 | if (files == null) { |
Philip Cuadra | d9bd884 | 2016-07-12 17:29:38 -0700 | [diff] [blame] | 251 | return true; |
| 252 | } |
| 253 | |
| 254 | //not pinning the oat/odex is not a fatal error |
Calin Juravle | 8e0f959 | 2017-05-15 20:20:50 -0700 | [diff] [blame] | 255 | for (String file : files) { |
| 256 | pf = pinFile(file, 0, 0, MAX_CAMERA_PIN_SIZE); |
| 257 | if (pf != null) { |
| 258 | mPinnedCameraFiles.add(pf); |
| 259 | if (DEBUG) { |
| 260 | Slog.i(TAG, "Pinned " + pf.mFilename); |
| 261 | } |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 262 | } |
| 263 | } |
Philip Cuadra | d9bd884 | 2016-07-12 17:29:38 -0700 | [diff] [blame] | 264 | |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 265 | return true; |
| 266 | } |
| 267 | |
| 268 | |
| 269 | /** mlock length bytes of fileToPin in memory, starting at offset |
| 270 | * length == 0 means pin from offset to end of file |
| 271 | * maxSize == 0 means infinite |
| 272 | */ |
| 273 | private static PinnedFile pinFile(String fileToPin, long offset, long length, long maxSize) { |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 274 | FileDescriptor fd = new FileDescriptor(); |
| 275 | try { |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 276 | fd = Os.open(fileToPin, |
| 277 | OsConstants.O_RDONLY | OsConstants.O_CLOEXEC | OsConstants.O_NOFOLLOW, |
| 278 | OsConstants.O_RDONLY); |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 279 | |
| 280 | StructStat sb = Os.fstat(fd); |
| 281 | |
| 282 | if (offset + length > sb.st_size) { |
| 283 | Os.close(fd); |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 284 | Slog.e(TAG, "Failed to pin file " + fileToPin + |
| 285 | ", request extends beyond end of file. offset + length = " |
| 286 | + (offset + length) + ", file length = " + sb.st_size); |
| 287 | return null; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | if (length == 0) { |
| 291 | length = sb.st_size - offset; |
| 292 | } |
| 293 | |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 294 | if (maxSize > 0 && length > maxSize) { |
| 295 | Slog.e(TAG, "Could not pin file " + fileToPin + |
| 296 | ", size = " + length + ", maxSize = " + maxSize); |
| 297 | Os.close(fd); |
| 298 | return null; |
| 299 | } |
| 300 | |
| 301 | long address = Os.mmap(0, length, OsConstants.PROT_READ, |
| 302 | OsConstants.MAP_PRIVATE, fd, offset); |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 303 | Os.close(fd); |
| 304 | |
| 305 | Os.mlock(address, length); |
| 306 | |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 307 | return new PinnedFile(address, length, fileToPin); |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 308 | } catch (ErrnoException e) { |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 309 | Slog.e(TAG, "Could not pin file " + fileToPin + " with error " + e.getMessage()); |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 310 | if(fd.valid()) { |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 311 | try { |
| 312 | Os.close(fd); |
| 313 | } |
| 314 | catch (ErrnoException eClose) { |
| 315 | Slog.e(TAG, "Failed to close fd, error = " + eClose.getMessage()); |
| 316 | } |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 317 | } |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 318 | return null; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 322 | private static boolean unpinFile(PinnedFile pf) { |
| 323 | try { |
| 324 | Os.munlock(pf.mAddress, pf.mLength); |
| 325 | } catch (ErrnoException e) { |
| 326 | Slog.e(TAG, "Failed to unpin file " + pf.mFilename + " with error " + e.getMessage()); |
| 327 | return false; |
| 328 | } |
| 329 | if (DEBUG) { |
| 330 | Slog.i(TAG, "Unpinned file " + pf.mFilename ); |
| 331 | } |
| 332 | return true; |
| 333 | } |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 334 | |
| 335 | private final class BinderService extends Binder { |
| 336 | @Override |
| 337 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 338 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); |
| 339 | pw.println("Pinned Files:"); |
Philip Cuadra | a95cea0 | 2016-07-06 16:00:32 -0700 | [diff] [blame] | 340 | synchronized(this) { |
| 341 | for (int i = 0; i < mPinnedFiles.size(); i++) { |
| 342 | pw.println(mPinnedFiles.get(i).mFilename); |
| 343 | } |
| 344 | for (int i = 0; i < mPinnedCameraFiles.size(); i++) { |
| 345 | pw.println(mPinnedCameraFiles.get(i).mFilename); |
| 346 | } |
Philip Cuadra | 7cb2f8b | 2016-06-15 16:23:43 -0700 | [diff] [blame] | 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | private static class PinnedFile { |
| 352 | long mAddress; |
| 353 | long mLength; |
| 354 | String mFilename; |
| 355 | |
| 356 | PinnedFile(long address, long length, String filename) { |
| 357 | mAddress = address; |
| 358 | mLength = length; |
| 359 | mFilename = filename; |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 360 | } |
| 361 | } |
Philip Cuadra | a95cea0 | 2016-07-06 16:00:32 -0700 | [diff] [blame] | 362 | |
| 363 | final class PinnerHandler extends Handler { |
| 364 | static final int PIN_CAMERA_MSG = 4000; |
| 365 | static final int PIN_ONSTART_MSG = 4001; |
| 366 | |
| 367 | public PinnerHandler(Looper looper) { |
| 368 | super(looper, null, true); |
| 369 | } |
| 370 | |
| 371 | @Override |
| 372 | public void handleMessage(Message msg) { |
| 373 | switch (msg.what) { |
| 374 | |
| 375 | case PIN_CAMERA_MSG: |
| 376 | { |
| 377 | handlePinCamera(msg.arg1); |
| 378 | } |
| 379 | break; |
| 380 | |
| 381 | case PIN_ONSTART_MSG: |
| 382 | { |
| 383 | handlePinOnStart(); |
| 384 | } |
| 385 | break; |
| 386 | |
| 387 | default: |
| 388 | super.handleMessage(msg); |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
Philip Cuadra | 7bd0fdd | 2016-04-28 15:26:49 -0700 | [diff] [blame] | 393 | } |